package com.njwb.day05;

public class TestSingleton {
    public static void main(String[] args) {
        //自定义一个类，让这个类的对象实例有且只有一个
        //懒汉
        Singleton s=Singleton.getSingleton();
        System.out.println(s);
        Singleton s2=Singleton.getSingleton();
        System.out.println(s2);
        Singleton s3=Singleton.getSingleton();
        System.out.println(s3);
        System.out.println();
        //饿汉
        Singleton2 s4=Singleton2.getSingleton();
        System.out.println(s4);
        Singleton2 s5=Singleton2.getSingleton();
        System.out.println(s5);
        Singleton2 s6=Singleton2.getSingleton();
        System.out.println(s6);


    }
}
